package cn.edu.cqvie.jdk8.joda;

import org.joda.time.DateTime;
import org.joda.time.LocalDate;

public class JodaTest1 {

    public static void main(String[] args) {

        DateTime toDay = new DateTime();
        DateTime tomorrow = toDay.plusDays(1);

        System.out.println(toDay.toString("yyyy-MM-dd"));
        System.out.println(tomorrow.toString("yyyy-MM-dd"));

        System.out.println("---------");

        DateTime dateTime = toDay.withDayOfMonth(1);
        System.out.println("yyyy-MM-dd");

        System.out.println("---------");

        LocalDate localDate = new LocalDate();
        System.out.println(localDate);
        System.out.println("---------");


        localDate = localDate.plusMonths(3).dayOfMonth().withMinimumValue();
        System.out.println(localDate);

        System.out.println("---------");

        //计算2年前第3个月最后1天的日期
        DateTime dateTime1 = new DateTime();
        DateTime dateTime2 = dateTime1.minusYears(2).monthOfYear().setCopy(3).dayOfMonth().withMinimumValue();
        System.out.println(dateTime2.toString("yyyy-MM-dd"));

    }
}
